package com.example.bruger.androidneurosky;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class BrainwaveActivity extends ActionBarActivity implements TGCallBack {

    int maxValue = 1000000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_brainwave);
        TGHandler.SetNewCallBack(this);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_brainwave, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void Update(int attention, int meditation, int delta, int theta,
                            int lowAlpha, int highAlpha, int lowBeta, int highBeta,
                            int lowGamma, int midGamma) {
        Log.v("Attention:", " " + attention);
        // Attention
                ((TextView) findViewById(R.id.attention_text)).setText("Attention: " + attention + " - " + attention + " %");
        ((ProgressBar) findViewById(R.id.attention_bar)).setProgress(attention);
        // Meditation
        ((TextView) findViewById(R.id.meditation_text)).setText("Meditation: " + meditation + " - " + meditation + " %");
        ((ProgressBar) findViewById(R.id.meditation_bar)).setProgress(meditation);
        // Delta
        ((TextView) findViewById(R.id.delta_text)).setText("Delta: " + delta + " - " + delta / maxValue + " %");
        ((ProgressBar) findViewById(R.id.delta_bar)).setProgress(delta / maxValue);
        // Theta
        ((TextView) findViewById(R.id.theta_text)).setText("Theta: " + theta + " - " + theta / maxValue + " %");
        ((ProgressBar) findViewById(R.id.theta_bar)).setProgress(theta / maxValue);
        // Low Alpha
        ((TextView) findViewById(R.id.lowAlpha_text)).setText("Low Alpha: " + lowAlpha + " - " + lowAlpha / maxValue + " %");
        ((ProgressBar) findViewById(R.id.lowAlpha_bar)).setProgress(lowAlpha / maxValue);
        // High Alpha
        ((TextView) findViewById(R.id.highAlpha_text)).setText("High Alpha: " + highAlpha + " - " + highAlpha / maxValue + " %");
        ((ProgressBar) findViewById(R.id.highAlpha_bar)).setProgress(highAlpha / maxValue);
        // Low Beta
        ((TextView) findViewById(R.id.lowBeta_text)).setText("Low Beta: " + lowBeta + " - " + lowBeta / maxValue + " %");
        ((ProgressBar) findViewById(R.id.lowBeta_bar)).setProgress(lowBeta / maxValue);
        // High Beta
        ((TextView) findViewById(R.id.highBeta_text)).setText("High Beta: " + highBeta + " - " + highBeta / maxValue + " %");
        ((ProgressBar) findViewById(R.id.highBeta_bar)).setProgress(highBeta / maxValue);
        // Low Gamma
        ((TextView) findViewById(R.id.lowGamma_text)).setText("Low Gamma: " + lowGamma + " - " + lowGamma / maxValue + " %");
        ((ProgressBar) findViewById(R.id.lowGamma_bar)).setProgress(lowGamma / maxValue);
        // Mid Gamma
        ((TextView) findViewById(R.id.midGamma_text)).setText("Mid Gamma: " + midGamma + " - " + midGamma / maxValue + " %");
        ((ProgressBar) findViewById(R.id.midGamma_bar)).setProgress(midGamma / maxValue);
    }
}